package com.prototype.deepshallowCopy;

public class People implements Cloneable{

    private String name ;

    private Integer age ;
    //为了外部修改方便，这里设置为public
    public People friend ;

    public People(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    protected Object clone() {
        People people = null ;
        try {
            people = (People) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return people;
    }

    @Override
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", friend=" + friend +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public People getFriend() {
        return friend;
    }

    public void setFriend(People friend) {
        this.friend = friend;
    }
}
